package com.mtl.stud.service.impl;

import com.mtl.stud.domain.StudInfo;
import com.mtl.stud.mapper.StudInfoMapper;
import com.mtl.stud.service.IStudInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.mtl.common.tool.model.Page;

import java.util.List;
/**
 *  服务实现类
 *
 * @author lsc
 * @since 2019-06-27
 */
@Service
public class StudInfoServiceImpl implements IStudInfoService {

    @Autowired
    private StudInfoMapper studInfoMapper;

    @Override
    public StudInfo findById(Integer id) {
        return studInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public Page<StudInfo> findPage(Integer page, Integer size) {
        PageHelper.startPage(page,size);
        List<StudInfo> studInfos=studInfoMapper.selectAll();
        return new Page<>(studInfos);
    }

    @Override
    public int saveOrUpdate(StudInfo studInfo) {
        if(studInfo.getId()!=null){
        return studInfoMapper.updateByPrimaryKey(studInfo);
        }
        return studInfoMapper.insert(studInfo);
    }

    @Override
    public int deleteBatch(List<Integer> ids) {
        return studInfoMapper.deleteByIdList(ids);
    }
}
